package com.reminiscence.main;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

import com.reminiscence.classes.Storia;
import com.reminiscence.classes.Utente;
import com.reminiscence.utils.Utils;

public class MainActivity extends Activity
{
	public static Utente utente = new Utente();
	public static Storia storia = new Storia();
	public static Context applicationContext;
	
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
		
		applicationContext = getApplicationContext();
     
		if (!Utils.isConnectingToInternet(applicationContext))
		{
			Toast.makeText(applicationContext, "Non sei connesso a internet", Toast.LENGTH_LONG).show();
			this.finish();
		}
	}
	
	public boolean onCreateOptionsMenu(Menu menu)
	{
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item)
	{
		switch (item.getItemId())
	    {
	    	/*case R.id.mnuRegistrazione:
	    	{
	    		Intent i = new Intent(this, Registrazione.class);
	    		startActivity(i);
	    		break;
	    	}*/
	    	
	    	case R.id.mnuConnessione:
	    	{
	    		Intent i = new Intent(this, Login.class);
	    		i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	    		startActivity(i);
	    		break;
	    	}
	    	
	    	case R.id.mnuManuale:
	    		Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://remin.site90.com/manuale/index.html"));
	    		startActivity(browserIntent);
	    		break;
	    	
    		default:
			break;
	    }

	    return true;
	}
	
}
